# -*- coding: utf-8 -*-
# @Time    : 2021/11/6 11:28
# @Author  : ydh
# @File    : CategoryInfo.py
# @Software: PyCharm
from django.db import models
from django.db.models import IntegerChoices


class CategoryInfo(models.Model):
    class CategoryNameChoice(IntegerChoices):
        ScienceFiction = 1, "科幻"
        SeriousLiterature = 2, "严肃文学"
        Novel = 3, "小说",
        Geographic = 4, "地理",
        Other = 99, "其他"

    category_name = models.IntegerField(
        unique=True,
        verbose_name="类型名称",
        null=True,
        blank=True,
        choices=CategoryNameChoice.choices,
        default=CategoryNameChoice.Other.value,
    )
    category_desc = models.TextField(verbose_name="类型描述", blank=True, null=True)

    class Meta:
        db_table = "TAB_CATEGORY"
        verbose_name = "类型名称"
        ordering = ["category_name"]

    def __str__(self):
        return f"{self.category_name}"
